import Cookies from "js-cookie";

const TokenKey = "Token";

export function getToken() {
  try {
    return JSON.parse(Cookies.get(TokenKey));
  } catch (error) {
    return undefined;
  }
}

export function setToken(token, time = 2) {
  return Cookies.set(TokenKey, JSON.stringify(token), { expires: time / 24 }); //默认两个小时
}
export function removeToken() {
  return Cookies.remove(TokenKey);
}
